package com.wq.myspring.beantest;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

/**
 * @PackageName: com.wq.myspring
 * @ClassName MyTest2
 * @Description: TODO
 * @Author Wenqiang
 * @Date 2021/07/16 14:27
 * @Version V1.0
 */
public class MyTest2 {
	public static void main(String[] args) {
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Conscan.class);
		User user = context.getBean("user", User.class);
		user.setName("李四");
		System.out.println(user);
	}
}

@ComponentScan("com.wq.myspring")
class Conscan {}

@Component
class User {
	private String name;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return "[" + hashCode() + "] User{" +
				"name='" + name + '\'' +
				'}';
	}
}

